/*
 * User.java
 *
 * Created on September 4, 2008, 6:44 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Project.bussiness;

import Project.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author haolt_c0708l
 */
public class User {
    
    private int UserID;
    private String UserName;
    private String password;

    public int getUserID() {
        return UserID;
    }

    public void setUserID(int UserID) {
        this.UserID = UserID;
    }

    public String getUserName() {
        return UserName;
    }

    public void setUserName(String UserName) {
        this.UserName = UserName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    public static Vector getAllUser() throws SQLException
    {
        Vector v = new Vector();
        try {
        ResultSet rs = DBHelper.executeQuery("spGetAllUsers");
            while(rs.next()){
            User u =new User();
            u.UserID=rs.getInt(1);
            u.UserName=rs.getString(2);
            u.password=rs.getString(3);
            v.add(u);
            }
        } catch(SQLException sqle) {
            throw sqle;
        }
        return v;        
    }     
    public static int changePassword(String pass) throws SQLException
    {
        int i;
        try{
            Vector paramList = new Vector();
            paramList.add(pass);   
            i=DBHelper.executeUpdate("spChangePassword",paramList);
        } catch(SQLException e)
        {
            throw e;
        }
        return i;
        
    }
}
